package com.cimu.consumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cimu.provider.entity.User;
import com.cimu.provider.service.AsyncService;
import com.cimu.provider.service.MockService;
import com.cimu.provider.service.OtherRegistryService;
import com.cimu.provider.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Title: UserController
 * Copyright: Copyright (c) 2017
 *
 * date 2018年12月06日 14:05
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Reference(check=true,registry = "test")
    private UserService userService;
    @Reference(mock="return 123",registry = "test")
    private MockService mockService;
    @Reference(registry = "test")
    private AsyncService asyncService;
    @Reference(registry = "test1" ,cache="lru")
    private OtherRegistryService otherRegistryService;

    @GetMapping("/get")
    public User getById(Long id){
        return userService.getById(id);
    }

    @GetMapping("/save")
    public Object getAll(){
        asyncService.saveUser();
        return "success";
    }

    @GetMapping("/mock")
    public Object mock(){
        return mockService.mockData();
    }

    @GetMapping("/registry")
    public void testMultiRegistry(){
        otherRegistryService.test();
    }

}
